<?php
  session_start();
  require 'include/configDB.php';
  $id = $_GET['id'];
  $query = mysql_query("SELECT * FROM kode_pos WHERE kode_pos=$id");
  $data = mysql_fetch_array($query);
   if (! isset($_SESSION['role']) || ($_SESSION['role'] != "Admin") && ($_SESSION['role'] != "Staff Tata Usaha")) {
  header('Location: login.php');
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Edit Kode Pos</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="ddaccordion.js"></script>
<script type="text/javascript">
ddaccordion.init({
	headerclass: "submenuheader", //Shared CSS class name of headers group
	contentclass: "submenu", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: false, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["suffix", "<img src='images/plus.gif' class='statusicon' />", "<img src='images/minus.gif' class='statusicon' />"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})
</script>

<script type="text/javascript" src="jconfirmaction.jquery.js"></script>
<script type="text/javascript">
	
	function allNumber(input){
    var numbers = /^[0-9]+$/;
    return numbers.test(input);
  }

  function allLetters(a) {
    var re = /^[A-Za-z\s]+$/;
    return re.test(a);
  }

  function validasi(){
    var kodepos = document.getElementById("kode_pos").value;
    var kota = document.getElementById("kota").value;
    var provinsi = document.getElementById("provinsi").value;

    if (kodepos == "") {
      alert("kodepos harus diisi!");
      return false;
    }

    if (kota == "") {
      alert("kota harus diisi!");
      return false;
    }

    if (provinsi == "") {
      alert("provinsi harus diisi!");
      return false;
    }

    if (!allNumber(kodepos)) {
      alert("kodepos harus angka semua!");
      return false;
    }

    if (!allLetters(kota)) {
      alert("kota harus huruf semua!");
      return false;
    }

    if (!allLetters(provinsi)) {
      alert("provinsi harus huruf semua!");
      return false;
    }

  }
	
</script>

<script language="javascript" type="text/javascript" src="niceforms.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="niceforms-default.css" />
<style>
      <?php include 'include_style.php'; ?>
</style>
</head>
<body>
<div id="main_container">

	 <?php include 'header.php'; ?>
    
    <div class="main_content">
                
                    
    <div class="center_content">  
		
    
	
    <div class="left_content">
    
    		<?php include 'left_content.php'; ?>
        <?php include 'calendar.php' ; ?>
        
    </div>  
    
    <div class="right_content">
		<h2>Edit Kode Pos</h2>
     	<div id="stylized" class="myform">
         	<form id="edit_kodepos" name="edit_kodepos" method="post" action="include/edit_kodepos.php" onsubmit='return validasi();'>
        		<h1>Kurikulum</h1>
      			<table>
                  <tr>
                       <td>
                       <label>Kode Pos
                            <span class="small">isi Kode Pos</span>
                        </label>
                        </td>
                        <td>
                          :
                        </td>
                        <td>
                        <input type="text" name="kode_pos" id="kode_pos" value="<?php echo $data['kode_pos'] ?>"  />
                        </td>
                  </tr>
                  <tr>
                       <td>
                       <label>Kota
                            <span class="small">isi Nama Kota</span>
                        </label>
                        </td>
                        <td>
                          :
                        </td>
                        <td>
                        <input type="text" name="kota" id="kota" value="<?php echo $data['kota'] ?>"/>
                        </td>
                  </tr>
                   <tr>
                       <td>
                       <label>Provinsi
                            <span class="small">isi Nama Provinsi</span>
                        </label>
                        </td>
                        <td>
                          :
                        </td>
                        <td>
                        <input type="text" name="provinsi" id="provinsi" value="<?php echo $data['provinsi'] ?>" />
                        </td>
                  </tr>

                  <tr>
                      <td><input type="submit" class="menuitem_red" name="submit" value="Simpan"/></td>
                  </tr>
          </table>
          <div class="spacer"></div>
          
          </form>
		</div>
		
    </div><!-- end of right content-->
            
                    
	</div>   <!--end of center content -->               
                    
                    
    
    
    <div class="clear"></div>
    </div> <!--end of main content-->
	
    
    <div class="footer">
          <?php include 'footer.php'; ?>

    	
    </div>

</div>		
</body>
</html>